package adc.budget.impl.hb.bo;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import adc.budget.spec.bo.IAccountType;

@Entity
@Table(name="ACCOUNT_TYPE")
public class HbAccountType extends HbBudgetBo implements IAccountType {

    private static final long serialVersionUID = 1L;

    private String name;
    private Boolean credit;

    @Override
    @Column(length=256)
    public String getName() {
        return name;
    }

    @Override
    public void setName(String name) {
        this.name = name;
    }

    @Override
    @Column(nullable=false)
    public Boolean getCredit() {
        return credit;
    }

    @Override
    public void setCredit(Boolean credit) {
        this.credit = credit;
    }

    @Override
    public boolean equals(final Object other) {
        if (this == other) {
            return true;
        }
        if (!(other instanceof HbAccountType)) {
            return false;
        }
        final HbAccountType otherAccType = (HbAccountType) other;
        return equals(this.getName(), otherAccType.getName());
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder().append(getName()).toHashCode();
    }

    @Override
    protected void appendPropsToString(final ToStringBuilder builder) {
        super.appendPropsToString(builder);
        builder.append("name", name).append("credit", credit);
        
    }
}
